import base64
def image_to_base64(image_path):
    with open(image_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read())
    return encoded_string.decode('utf-8')

# 示例用法，将此处的路径替换成你实际的图片路径
image_path = "./2.jpg"
base64_result = image_to_base64(image_path)
print(base64_result)